package com.vodone.v1pin.detail.vo
{
	import com.vodone.v1pin.component.productlist.MyProductList;
	import com.vodone.v1pin.core.utils.GoodsUtil;
	import com.vodone.v1pin.productlist.vo.ProductListVO;
	import com.vodone.v1pin.productlist.vo.QueryItemVO;
	
	import mx.collections.ArrayCollection;

	[Bindable]
	public class ProductDetailVO
	{
		public function ProductDetailVO( obj:Object = null )
		{
			if( null != obj )
			{
				parseData( obj );
			}
		}
		
		public function get showSize():Boolean
		{
			return this.sizeColumns != null || this.sizePic != null;
		}
		
		private function parseData( obj:Object ):void
		{
			if( obj.hasOwnProperty("id") )
			{
				this.id = obj["id"];
			}
			if( obj.hasOwnProperty("isFavor") )
			{
				this.isFavor = Boolean( obj["isFavor"] );
			}
			if( obj.hasOwnProperty("name") )
			{
				this.name = obj["name"];
			}
			if( obj.hasOwnProperty("totalCount") )
			{
				this.totalCount = obj["totalCount"];
			}
			if( obj.hasOwnProperty("productSource") )
			{
				this.productSource = obj["productSource"];
			}
			if( obj.hasOwnProperty("number") )
			{
				this.number = obj["number"];
			}
			if( obj.hasOwnProperty("video") )
			{
				this.video = obj["video"];
			}
			if( obj.hasOwnProperty("dsptl") )
			{
				this.dsptl = obj["dsptl"];
			}
			if( obj.hasOwnProperty("brandDspt") )
			{
				this.brandDspt = obj["brandDspt"];
			}
			if( obj.hasOwnProperty("brand") )
			{
				this.brand = obj["brand"];
			}
			if( obj.hasOwnProperty("color") )
			{
				this.color = new QueryItemVO( obj["color"] );
			}
			if( obj.hasOwnProperty("category") )
			{
				this.category = obj["category"];
			}
			if( obj.hasOwnProperty("mainPic") )
			{
				this.mainPic = new QueryItemVO( obj["mainPic"] );
			}
			if( obj.hasOwnProperty("defaultSizeId") )
			{
				this.defaultSizeId = obj["defaultSizeId"];
			}
			if( obj.hasOwnProperty("price") )
			{
				this.price = Number( obj["price"] );
			}
			if( obj.hasOwnProperty("salePrice") )
			{
				this.salePrice = Number( obj["salePrice"] );
			}
			
			if( obj.hasOwnProperty("v1pinPrice") )
			{
				this.v1pinPrice = Number( obj["v1pinPrice"] );
			}
			if( obj.hasOwnProperty("sizePic") )
			{
				this.sizePic = obj["sizePic"];
			}
			
			if( obj.hasOwnProperty("detailList") )
			{
				this.detailList = ProductListVO.parseList( obj , "detailList" , QueryItemVO );
			}
			if( obj.hasOwnProperty("picList") )
			{
				this.picList = ProductListVO.parseList( obj , "picList" , QueryItemVO );
				picList.addItemAt( mainPic , 0 ); 
			}
			if( obj.hasOwnProperty("packpicList") )
			{
				this.packpicList = ProductListVO.parseList( obj , "packpicList" , QueryItemVO );
			}
			if( obj.hasOwnProperty("colorList") )
			{
				this.colorList = ProductListVO.parseList( obj , "colorList" , QueryItemVO , 8 );
			}
			if( obj.hasOwnProperty("sizelist") )
			{
				this.sizelist = ProductListVO.parseList( obj , "sizelist" , QueryItemVO );
			}
			if( obj.hasOwnProperty("sizeColumns") )
			{
				if( obj["sizeColumns"] == null )
				{
					this.sizeColumns = null;
				}
				else
				{
					this.sizeColumns = ProductListVO.parseList( obj , "sizeColumns" , String  );
				}
			}
			if( obj.hasOwnProperty("recommendList") )
			{
				this.recommendList = ProductListVO.parseList( obj , "recommendList" , QueryItemVO , 4 );
			}
			if( obj.hasOwnProperty("sizeDetailList") )
			{
				var arr:Array = obj["sizeDetailList"] as Array;
				arr ||= [];
				var result:Array = [];
				for( var i:int = 0 ; i < arr.length ; i++ )
				{
					var itemArr:Array = arr[ i ] as Array;
					var item:Object = {};
					for( var j:int = 0 ; j < itemArr.length ; j++ )
					{
						item[ "p" + j ] = itemArr[j];
					}
					result.push(item);
				}
				this.sizeDetailList = new ArrayCollection( result );
			}
		}
		/**
		 * 产品id 
		 */		
		public var id:String = "";
		/**
		 * 产品名称 
		 */		
		public var name:String = "";
		/**
		 * 编号 
		 */		
		public var number:String = "";
		/**
		 * 产品描述
		 */		
		public var dsptl:String = "";
		/**
		 * 品牌描述 
		 */		
		public var brandDspt:String = "";
		/**
		 * 是否收藏 
		 */		
		public var isFavor:Boolean = false;
		/**
		 * 商品描述中的动态部分 
		 */		
		public var detailList:ArrayCollection;
		/**
		 * 品牌id
		 */		
		public var brand:String = "";
		/**
		 * 颜色id 
		 */		
		public var color:QueryItemVO;
		/**
		 * 类别 
		 */		
		public var category:String = "";
		/**
		 * 主图地址 
		 */		
		public var mainPic:QueryItemVO;
		/**
		 * 图片地址 
		 */		
		public var picList:ArrayCollection;
		/**
		 * 包装图片地址 
		 */		
		public var packpicList:ArrayCollection;
		/**
		 * 市场价 
		 */		
		public var price:Number = 0;
		/**
		 * v1品价格 
		 */		
		public var v1pinPrice:Number = 0;
		/**
		 * 促销价
		 */		
		public var salePrice:Number = -1;
		/**
		 * 颜色列表，元素为QueryItemVO
		 */		
		public var colorList:ArrayCollection;
		/**
		 * 尺寸列表，元素为 QueryItemVO
		 */		
		public var sizelist:ArrayCollection;
		/**
		 * 默认尺码id 
		 */		
		public var defaultSizeId:String = "";
		/**
		 * 尺寸图片 
		 */		
		public var sizePic:String;
		/**
		 * 尺寸列，动态
		 */		
		public var sizeColumns:ArrayCollection;
		/**
		 * 尺寸数据，动态，二维
		 */		
		public var sizeDetailList:ArrayCollection;
		/**
		 * 推荐列表
		 */		
		public var recommendList:ArrayCollection;
		/**
		 * 视频地址 
		 */		
		public var video:String;
		/**
		 * 剩余数量 
		 */		
		public var totalCount:uint = 0;
		/**
		 * 出产厂商
		 */		
		public var productSource:String = "";
	}
}